<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Warehouse Transfer IN </title>
<script language="javascript">
function enableUpload(){
	document.getElementById("sub_upload").disabled = false;
	}

</script>
</head>
<body style="font-family:Arial, Helvetica, sans-serif;">

<h1>Repair Parts Transfer (TI/TO)</h1>
<p>
<span style="color:#F00"><?php echo $this->errorMessage;?></span><br />
  ***********************************<br />
  This Function now is only for Steven Tranfer from SHOP ID 3 To Other Shops 
  <br />
  1.Scan Barcode and Input the Qty<br />
  2.Click 
  &quot;Add Record&quot;<br />
  3.You may Click The &quot;Remove&quot; Button if You Made Mistakes<br />
  4.After All Record Scaned ,Fill In Your Name<br />
5.Finally,Click &quot;Save These Records&quot;<br />
  *********************************** <br />
  Error Correction Function <br />
  ***********************************
  <br />
</p>
<p><br />
  
  <?php
$arrProducts = array();
$end = 0;

if($_POST){
	//unset($arrProducts);
	$arrProducts = unserialize(base64_decode(trim($_POST['saved_arr'])));
	//echo $_POST['saved_arr'];
	$end = count($arrProducts);
	$tmpstr = trim($_POST['barcode_code'])."[".trim($_POST['barcode_qty'])."]";
	$arrProducts[$end] = $tmpstr;
	//var_dump($arrProducts);	
	}
if(isset($_GET['rm'])){
	
	$i = $_GET['rm'];
	//echo $i;
	$arrProducts = unserialize(base64_decode(trim($_GET['data'])));
	array_splice($arrProducts,$i,1);
	}	

?>
</p>
<table width="800" border="0" cellspacing="1" cellpadding="5" bgcolor="#333">
<tr>
    <td bgcolor="#FFFFFF">Scan Barcode Transfer:<br /></td>
    <td bgcolor="#FFFFFF">
    <form id="form1" name="form1" method="post" action="/repairparts/shop-to-shop-transfer/transferpass/<?php echo $this->pass?>">
    
      <input type="text" name="barcode_code" id="barcode_code" /> 
      Qty:
[      
<label for="textfield2"></label>
      <input type="text" name="barcode_qty" id="barcode_qty" width="50" value="1" />
      ]
       <input type="hidden" name="saved_arr" id="saved_arr" value="<?php echo base64_encode(trim(serialize($arrProducts)));?>"/>
      <input type="button" name="button" id="button" value="Add Record" onclick="javascript:document.form1.submit();" />
      </form>
      </td>
  </tr>
  <tr>
    <td width="150" bgcolor="#FFFFFF">Records to Save:</td>
    <td bgcolor="#FFFFFF"><form id="form2" name="form2" method="post" action="/repairparts/save-shop-to" >

      <table width="100%" border="0" cellspacing="0" cellpadding="3">
        <tr>
          <td style="width:40%">Shop ID:</td>
          <td><label for="id_shop"></label>
            <input name="id_shop" type="hidden" id="id_shop" value="3" /> 
            ID 3 (Warehouse Steven)</td>
        </tr>
        <tr>
          <td>Shop Transfer To:</td>
          <td>
            <select name="id_shop_to" id="id_shop_to">
              <option value="14">FGIC</option>
              <option value="15">PMIC</option>
              <option value="1">BaySide Shops</option>
              <option value="2">CSIC</option>
              <option value="4">BHPC</option>
              <option value="5">HPIC</option>
              <option value="6">CBPC</option>
              <option value="7">Sa Shops</option>
              <option value="8">EPPC</option>
              <option value="9">Wb Shops</option>
              <option value="10">NLPC</option>
              <option value="11">DCIC</option>
              <option value="12">KCPC</option>
              <option value="13">SLIC</option>
              <option value="16">WGIC</option>
              <option value="18">BBPC</option>
            </select></td>
        </tr>
        <tr>
          <td>Staff Name:</td>
          <td><input type="text" name="staff_name" id="staff_name"
         <?php if($this->errorMessage == ""){?>
           onchange="enableUpload()" 
         <?php }?>  
           />
          
            <input type="hidden" name="shop_head" id="shop_head" value="<?php echo $this->shopHead?>" /></td>
        </tr>
      </table>
      <p>
        
        <input name="sub_upload" id="sub_upload" value="SAVE THESE RECORDS" type="submit" disabled="disabled" /><br />
        </p>
      <hr />
        Part(s) 
        Needs Transfer
        <hr />
      <table width="100%" border="0" cellspacing="0" cellpadding="3" style="font-size:11px;">
  <tr>
    <td width="150">Code</td>
    <td>Description(If you can not see the descripton, you barcode is incorrect)</td>
    <td width="100">Qty</td>
    <td width="50">Action</td>
  </tr>
      <?php
	
    foreach($arrProducts as $key => $value){
			//echo $value;
	$valArr = explode("[",$value,2);
	?>   
  
  <tr>
    <td><?php echo $valArr[0]?></td>
    <td><?php
   $rProducts = new Model_DbTable_Pr_Prproducts();
   echo $rProducts->getProductDes($valArr[0]); 
	?>
    </td>
    <td>[<?php echo $valArr[1]?>  Pcs</td>
    <td>
	<?php 
	echo "<input type=\"hidden\" name=\"upload[]\" value=\"".$value."\" />";
	echo "<a href=\"?rm=".$key."&data=".base64_encode(trim(serialize($arrProducts)))."\">Remove</a><br />";?></td>
  </tr>
<?php

	}
?>

</table>
  

    <br />

    
    </form></td>
  </tr>
  
</table>
    <script language="javascript">
    document.getElementById('barcode_code').focus(); 
    </script> 
</body>
</html>
